package main

import "fmt"

type Person struct {
	Name string `json:"name"`
}

func main() {
	person := NewPerson("zs")
	person1 := person.clone()
	person2 := person //浅copy

	person1.Name = "ls"
	person2.Name = "allen"
	fmt.Println(person, person1, person2)
}

func NewPerson(name string) *Person {
	return &Person{Name: name}
}

func (person *Person) clone() *Person {
	//深copy
	np := *person
	ret := &np
	return ret
}
